package com.d3works.apps.account.service;

import com.d3works.apps.account.db.Invoice;
import com.d3works.apps.account.db.SubrogationRelease;
import com.d3works.apps.base.db.Company;
import com.d3works.exception.D3worksException;
import java.io.IOException;
import java.util.List;

public interface SubrogationReleaseService {

  /**
   * Retrieve ventilated invoices from factorized customers.
   *
   * @param company
   * @return
   */
  List<Invoice> retrieveInvoices(Company company);

  /**
   * Transmit a subrogation release (generate a sequence number and change status).
   *
   * @param subrogationRelease
   * @throws D3worksException
   */
  void transmitRelease(SubrogationRelease subrogationRelease) throws D3worksException;

  /**
   * Generate a PDF export.
   *
   * @param subrogationRelease
   * @param name
   * @return
   * @throws D3worksException
   */
  String printToPDF(SubrogationRelease subrogationRelease, String name) throws D3worksException;

  /**
   * Generate a CSV export.
   *
   * @param subrogationRelease
   * @return
   * @throws D3worksException
   * @throws IOException
   */
  String exportToCSV(SubrogationRelease subrogationRelease) throws D3worksException, IOException;

  /**
   * Enter a subrogation release in the accounts (create moves).
   *
   * @param subrogationRelease
   * @throws D3worksException
   */
  void enterReleaseInTheAccounts(SubrogationRelease subrogationRelease) throws D3worksException;

  /**
   * Clear the subrogation release
   *
   * @param subrogationRelease
   */
  void clear(SubrogationRelease subrogationRelease);

  /**
   * Check if the all invoice of the subrogation release are completely cleared
   *
   * @param subrogationRelease
   * @return
   */
  boolean isSubrogationReleaseCompletelyPaid(SubrogationRelease subrogationRelease);
}
